Let GPX parse geocaching-specific descriptions & hints.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 30 Jan 2004 20:00:43 +0000 (20:00 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 30 Jan 2004 20:00:43 +0000 (20:00 +0000)
Add string to decompse UTF to ASCII.

gpsbabel/defs.h
gpsbabel/gpx.c

index 8df87611532aea0451ee9fb29656ab662fcf9559..46a13ed55e2ef2b4a4b93b2560e06cd0eec05f1b 100644 (file)
@@ -101,6 +101,9 @@ typedef struct {
        int diff; /* (multiplied by ten internally) */
        int terr; /* (likewise) */
        time_t exported;
+       char *hint; /* all these UTF8, XML entities removed, May be not HTML. */
+       char *desc_short;
+       char *desc_long; 
 } geocache_data ;
 
 
@@ -389,6 +392,7 @@ signed int get_tz_offset(void);
 const char *get_cache_icon(const waypoint *waypointp);
 char * xml_entitize(const char * str);
 char * str_utf8_to_cp1252( const char * str );
+char * str_utf8_to_ascii( const char * str );
 
 /*
  * PalmOS records like fixed-point numbers, which should be rounded
index 7dff24541f969432c4159bdd52c3c9400dc15e17..627e51b9a49791645d4305541a69cae1f9f65541 100644 (file)
@@ -39,6 +39,7 @@ static char *gpx_author = NULL;
 vmem_t current_tag;
 
 static waypoint *wpt_tmp;
+static int cache_descr_is_html;
 static FILE *fd;
 static FILE *ofd;
 static void *mkshort_handle;
@@ -79,6 +80,9 @@ typedef enum {
        tt_cache_container,
        tt_cache_difficulty,
        tt_cache_terrain,
+       tt_cache_hint,
+       tt_cache_desc_short,
+       tt_cache_desc_long,
        tt_cache_log_wpt,
        tt_rte,
        tt_rte_name,
@@ -142,6 +146,9 @@ tag_mapping tag_path_map[] = {
        { tt_cache_container, 1, "/gpx/wpt/groundspeak:cache/groundspeak:container" },
        { tt_cache_difficulty, 1, "/gpx/wpt/groundspeak:cache/groundspeak:difficulty" },
        { tt_cache_terrain, 1, "/gpx/wpt/groundspeak:cache/groundspeak:terrain" },
+       { tt_cache_hint, 1, "/gpx/wpt/groundspeak:cache/groundspeak:encoded_hints" },
+       { tt_cache_desc_short, 1, "/gpx/wpt/groundspeak:cache/groundspeak:short_description" },
+       { tt_cache_desc_long, 1, "/gpx/wpt/groundspeak:cache/groundspeak:long_description" },
        { tt_cache_log_wpt, 1, "/gpx/wpt/groundspeak:cache/groundspeak:logs/groundspeak:log/groundspeak:log_wpt" },
 
        { tt_rte, 0, "/gpx/rte" },
@@ -248,6 +255,21 @@ tag_wpt(const char **attrv)
        }
 }
 
+static void
+tag_cache_desc(const char ** attrv)
+{
+       const char **avp;
+
+       cache_descr_is_html = 0;
+       for (avp = &attrv[0]; *avp; avp+=2) {
+               if (strcmp(avp[0], "html") == 0) {
+                       if (strcmp(avp[1], "True") == 0) {
+                               cache_descr_is_html = 1;
+                       }
+               }
+       }
+}
+
 static void
 start_something_else(const char *el, const char **attrv)
 {
@@ -404,6 +426,11 @@ gpx_start(void *data, const char *el, const char **attr)
        case tt_cache_log_wpt:
                if (opt_logpoint)
                        tag_log_wpt(attr);
+               break;
+       case tt_cache_desc_long:
+       case tt_cache_desc_short:
+               tag_cache_desc(attr);
+               break;
        }
        if (passthrough) {
                start_something_else(el, attr);
@@ -574,6 +601,24 @@ gpx_end(void *data, const char *el)
                sscanf(cdatastrp, "%f", &x);
                wpt_tmp->gc_data.diff = x * 10;
                break;
+       case tt_cache_hint:
+               rtrim(cdatastrp);
+               if (cdatastrp[0]) {
+                       wpt_tmp->gc_data.hint = xstrdup(cdatastrp);
+               }
+               break;
+       case tt_cache_desc_long:
+               rtrim(cdatastrp);
+               if (cdatastrp[0]) {
+                       wpt_tmp->gc_data.desc_long = xstrdup(cdatastrp);
+               }
+               break;
+       case tt_cache_desc_short:
+               rtrim(cdatastrp);
+               if (cdatastrp[0]) {
+                       wpt_tmp->gc_data.desc_short = xstrdup(cdatastrp);
+               }
+               break;
        case tt_cache_terrain:
                sscanf(cdatastrp, "%f", &x);
                wpt_tmp->gc_data.terr = x * 10;